﻿using System;
using fastCSharp.code.cSharp;

namespace diantou.web
{
    /// <summary>
    /// 用户调用
    /// </summary>
    abstract class userHandle<callType> : webView.view<callType>, webView.IWebView
        where callType : userHandle<callType>
    {
        /// <summary>
        /// 当前用户
        /// </summary>
        private diantou.dataAccess.user currentUserValue;
        /// <summary>
        /// 当前用户
        /// </summary>
        protected diantou.dataAccess.user currentUser
        {
            get
            {
                if (currentUserValue == null)
                {
                    currentUserValue = pub.GetCurrentUser(this) ?? diantou.dataAccess.user.NullUser;
                }
                return currentUserValue != diantou.dataAccess.user.NullUser ? currentUserValue : null;
            }
        }
        /// <summary>
        /// 当前用户(用于AJAX请求)
        /// </summary>
        protected diantou.dataAccess.user sessionUser
        {
            get
            {
                if (currentUserValue == null)
                {
                    currentUserValue = pub.GetSessionUser(this) ?? diantou.dataAccess.user.NullUser;
                }
                return currentUserValue != diantou.dataAccess.user.NullUser ? currentUserValue : null;
            }
        }
        /// <summary>
        /// 清除数据
        /// </summary>
        protected override void clear()
        {
            base.clear();
            currentUserValue = null;
        }
    }
}
